package Models;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.map.TableMap;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;





/**
 * Table Groupe
 *
 * This class was autogenerated by Torque on:
 *
 * [Wed Jan 09 17:54:44 CET 2013]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Groupe
 */
public abstract class BaseGroupe extends BaseObject
{
    /** Serial version */
    private static final long serialVersionUID = 1357750484946L;

    /** The Peer class */
    private static final GroupePeer peer =
        new GroupePeer();


    /** The value for the idGroupe field */
    private int idGroupe;

    /** The value for the nom field */
    private String nom;


    /**
     * Get the IdGroupe
     *
     * @return int
     */
    public int getIdGroupe()
    {
        return idGroupe;
    }


    /**
     * Set the value of IdGroupe
     *
     * @param v new value
     */
    public void setIdGroupe(int v) throws TorqueException
    {

        if (this.idGroupe != v)
        {
            this.idGroupe = v;
            setModified(true);
        }



        // update associated ModuleGroupe
        if (collModuleGroupes != null)
        {
            for (int i = 0; i < collModuleGroupes.size(); i++)
            {
                ((ModuleGroupe) collModuleGroupes.get(i))
                        .setIdGroupe(v);
            }
        }

        // update associated Etudiant
        if (collEtudiants != null)
        {
            for (int i = 0; i < collEtudiants.size(); i++)
            {
                ((Etudiant) collEtudiants.get(i))
                        .setIdGroupe(v);
            }
        }
    }

    /**
     * Get the Nom
     *
     * @return String
     */
    public String getNom()
    {
        return nom;
    }


    /**
     * Set the value of Nom
     *
     * @param v new value
     */
    public void setNom(String v) 
    {

        if (!ObjectUtils.equals(this.nom, v))
        {
            this.nom = v;
            setModified(true);
        }


    }

       


    /**
     * Collection to store aggregation of collModuleGroupes
     */
    protected List collModuleGroupes;

    /**
     * Temporary storage of collModuleGroupes to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initModuleGroupes()
    {
        if (collModuleGroupes == null)
        {
            collModuleGroupes = new ArrayList();
        }
    }


    /**
     * Method called to associate a ModuleGroupe object to this object
     * through the ModuleGroupe foreign key attribute
     *
     * @param l ModuleGroupe
     * @throws TorqueException
     */
    public void addModuleGroupe(ModuleGroupe l) throws TorqueException
    {
        getModuleGroupes().add(l);
        l.setGroupe((Groupe) this);
    }

    /**
     * Method called to associate a ModuleGroupe object to this object
     * through the ModuleGroupe foreign key attribute using connection.
     *
     * @param l ModuleGroupe
     * @throws TorqueException
     */
    public void addModuleGroupe(ModuleGroupe l, Connection con) throws TorqueException
    {
        getModuleGroupes(con).add(l);
        l.setGroupe((Groupe) this);
    }

    /**
     * The criteria used to select the current contents of collModuleGroupes
     */
    private Criteria lastModuleGroupesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getModuleGroupes(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getModuleGroupes()
        throws TorqueException
    {
        if (collModuleGroupes == null)
        {
            collModuleGroupes = getModuleGroupes(new Criteria(10));
        }
        return collModuleGroupes;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Groupe has previously
     * been saved, it will retrieve related ModuleGroupes from storage.
     * If this Groupe is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getModuleGroupes(Criteria criteria) throws TorqueException
    {
        if (collModuleGroupes == null)
        {
            if (isNew())
            {
               collModuleGroupes = new ArrayList();
            }
            else
            {
                criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe() );
                collModuleGroupes = ModuleGroupePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe());
                if (!lastModuleGroupesCriteria.equals(criteria))
                {
                    collModuleGroupes = ModuleGroupePeer.doSelect(criteria);
                }
            }
        }
        lastModuleGroupesCriteria = criteria;

        return collModuleGroupes;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getModuleGroupes(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getModuleGroupes(Connection con) throws TorqueException
    {
        if (collModuleGroupes == null)
        {
            collModuleGroupes = getModuleGroupes(new Criteria(10), con);
        }
        return collModuleGroupes;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Groupe has previously
     * been saved, it will retrieve related ModuleGroupes from storage.
     * If this Groupe is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getModuleGroupes(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collModuleGroupes == null)
        {
            if (isNew())
            {
               collModuleGroupes = new ArrayList();
            }
            else
            {
                 criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe());
                 collModuleGroupes = ModuleGroupePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe());
                 if (!lastModuleGroupesCriteria.equals(criteria))
                 {
                     collModuleGroupes = ModuleGroupePeer.doSelect(criteria, con);
                 }
             }
         }
         lastModuleGroupesCriteria = criteria;

         return collModuleGroupes;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Groupe is new, it will return
     * an empty collection; or if this Groupe has previously
     * been saved, it will retrieve related ModuleGroupes from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Groupe.
     */
    protected List getModuleGroupesJoinModule(Criteria criteria)
        throws TorqueException
    {
        if (collModuleGroupes == null)
        {
            if (isNew())
            {
               collModuleGroupes = new ArrayList();
            }
            else
            {
                criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe());
                collModuleGroupes = ModuleGroupePeer.doSelectJoinModule(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe());
            if (!lastModuleGroupesCriteria.equals(criteria))
            {
                collModuleGroupes = ModuleGroupePeer.doSelectJoinModule(criteria);
            }
        }
        lastModuleGroupesCriteria = criteria;

        return collModuleGroupes;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Groupe is new, it will return
     * an empty collection; or if this Groupe has previously
     * been saved, it will retrieve related ModuleGroupes from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Groupe.
     */
    protected List getModuleGroupesJoinGroupe(Criteria criteria)
        throws TorqueException
    {
        if (collModuleGroupes == null)
        {
            if (isNew())
            {
               collModuleGroupes = new ArrayList();
            }
            else
            {
                criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe());
                collModuleGroupes = ModuleGroupePeer.doSelectJoinGroupe(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(ModuleGroupePeer.ID_GROUPE, getIdGroupe());
            if (!lastModuleGroupesCriteria.equals(criteria))
            {
                collModuleGroupes = ModuleGroupePeer.doSelectJoinGroupe(criteria);
            }
        }
        lastModuleGroupesCriteria = criteria;

        return collModuleGroupes;
    }





    /**
     * Collection to store aggregation of collEtudiants
     */
    protected List collEtudiants;

    /**
     * Temporary storage of collEtudiants to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initEtudiants()
    {
        if (collEtudiants == null)
        {
            collEtudiants = new ArrayList();
        }
    }


    /**
     * Method called to associate a Etudiant object to this object
     * through the Etudiant foreign key attribute
     *
     * @param l Etudiant
     * @throws TorqueException
     */
    public void addEtudiant(Etudiant l) throws TorqueException
    {
        getEtudiants().add(l);
        l.setGroupe((Groupe) this);
    }

    /**
     * Method called to associate a Etudiant object to this object
     * through the Etudiant foreign key attribute using connection.
     *
     * @param l Etudiant
     * @throws TorqueException
     */
    public void addEtudiant(Etudiant l, Connection con) throws TorqueException
    {
        getEtudiants(con).add(l);
        l.setGroupe((Groupe) this);
    }

    /**
     * The criteria used to select the current contents of collEtudiants
     */
    private Criteria lastEtudiantsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getEtudiants(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getEtudiants()
        throws TorqueException
    {
        if (collEtudiants == null)
        {
            collEtudiants = getEtudiants(new Criteria(10));
        }
        return collEtudiants;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Groupe has previously
     * been saved, it will retrieve related Etudiants from storage.
     * If this Groupe is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getEtudiants(Criteria criteria) throws TorqueException
    {
        if (collEtudiants == null)
        {
            if (isNew())
            {
               collEtudiants = new ArrayList();
            }
            else
            {
                criteria.add(EtudiantPeer.ID_GROUPE, getIdGroupe() );
                collEtudiants = EtudiantPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(EtudiantPeer.ID_GROUPE, getIdGroupe());
                if (!lastEtudiantsCriteria.equals(criteria))
                {
                    collEtudiants = EtudiantPeer.doSelect(criteria);
                }
            }
        }
        lastEtudiantsCriteria = criteria;

        return collEtudiants;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getEtudiants(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getEtudiants(Connection con) throws TorqueException
    {
        if (collEtudiants == null)
        {
            collEtudiants = getEtudiants(new Criteria(10), con);
        }
        return collEtudiants;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Groupe has previously
     * been saved, it will retrieve related Etudiants from storage.
     * If this Groupe is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getEtudiants(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collEtudiants == null)
        {
            if (isNew())
            {
               collEtudiants = new ArrayList();
            }
            else
            {
                 criteria.add(EtudiantPeer.ID_GROUPE, getIdGroupe());
                 collEtudiants = EtudiantPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(EtudiantPeer.ID_GROUPE, getIdGroupe());
                 if (!lastEtudiantsCriteria.equals(criteria))
                 {
                     collEtudiants = EtudiantPeer.doSelect(criteria, con);
                 }
             }
         }
         lastEtudiantsCriteria = criteria;

         return collEtudiants;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Groupe is new, it will return
     * an empty collection; or if this Groupe has previously
     * been saved, it will retrieve related Etudiants from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Groupe.
     */
    protected List getEtudiantsJoinGroupe(Criteria criteria)
        throws TorqueException
    {
        if (collEtudiants == null)
        {
            if (isNew())
            {
               collEtudiants = new ArrayList();
            }
            else
            {
                criteria.add(EtudiantPeer.ID_GROUPE, getIdGroupe());
                collEtudiants = EtudiantPeer.doSelectJoinGroupe(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(EtudiantPeer.ID_GROUPE, getIdGroupe());
            if (!lastEtudiantsCriteria.equals(criteria))
            {
                collEtudiants = EtudiantPeer.doSelectJoinGroupe(criteria);
            }
        }
        lastEtudiantsCriteria = criteria;

        return collEtudiants;
    }



        
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
            fieldNames.add("IdGroupe");
            fieldNames.add("Nom");
            fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by field (Java) name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
        if (name.equals("IdGroupe"))
        {
            return new Integer(getIdGroupe());
        }
        if (name.equals("Nom"))
        {
            return getNom();
        }
        return null;
    }

    /**
     * Set a field in the object by field (Java) name.
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByName(String name, Object value )
        throws TorqueException, IllegalArgumentException
    {
        if (name.equals("IdGroupe"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setIdGroupe(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Nom"))
        {
            // Object fields can be null
            if (value != null && ! String.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setNom((String) value);
            return true;
        }
        return false;
    }

    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
        if (name.equals(GroupePeer.ID_GROUPE))
        {
            return new Integer(getIdGroupe());
        }
        if (name.equals(GroupePeer.NOM))
        {
            return getNom();
        }
        return null;
    }

    /**
     * Set field values by Peer Field Name
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPeerName(String name, Object value)
        throws TorqueException, IllegalArgumentException
    {
      if (GroupePeer.ID_GROUPE.equals(name))
        {
            return setByName("IdGroupe", value);
        }
      if (GroupePeer.NOM.equals(name))
        {
            return setByName("Nom", value);
        }
        return false;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
        if (pos == 0)
        {
            return new Integer(getIdGroupe());
        }
        if (pos == 1)
        {
            return getNom();
        }
        return null;
    }

    /**
     * Set field values by its position (zero based) in the XML schema.
     *
     * @param position The field position
     * @param value field value
     * @return True if value was set, false if not (invalid position / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPosition(int position, Object value)
        throws TorqueException, IllegalArgumentException
    {
    if (position == 0)
        {
            return setByName("IdGroupe", value);
        }
    if (position == 1)
        {
            return setByName("Nom", value);
        }
        return false;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
        save(GroupePeer.DATABASE_NAME);
    }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
     *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
        try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
    }

    /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
        if (!alreadyInSave)
        {
            alreadyInSave = true;



            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    GroupePeer.doInsert((Groupe) this, con);
                    setNew(false);
                }
                else
                {
                    GroupePeer.doUpdate((Groupe) this, con);
                }
            }


            if (collModuleGroupes != null)
            {
                for (int i = 0; i < collModuleGroupes.size(); i++)
                {
                    ((ModuleGroupe) collModuleGroupes.get(i)).save(con);
                }
            }

            if (collEtudiants != null)
            {
                for (int i = 0; i < collEtudiants.size(); i++)
                {
                    ((Etudiant) collEtudiants.get(i)).save(con);
                }
            }
            alreadyInSave = false;
        }
    }


    /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param key idGroupe ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
        setIdGroupe(((NumberKey) key).intValue());
    }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
        setIdGroupe(Integer.parseInt(key));
    }


    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
        return SimpleKey.keyFor(getIdGroupe());
    }
 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     */
    public Groupe copy() throws TorqueException
    {
        return copy(true);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     *
     * @param con the database connection to read associated objects.
     */
    public Groupe copy(Connection con) throws TorqueException
    {
        return copy(true, con);
    }

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     */
    public Groupe copy(boolean deepcopy) throws TorqueException
    {
        return copyInto(new Groupe(), deepcopy);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     * @param con the database connection to read associated objects.
     */
    public Groupe copy(boolean deepcopy, Connection con) throws TorqueException
    {
        return copyInto(new Groupe(), deepcopy, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     */
    protected Groupe copyInto(Groupe copyObj) throws TorqueException
    {
        return copyInto(copyObj, true);
    }

  
    /**
     * Fills the copyObj with the contents of this object using connection.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param con the database connection to read associated objects.
     */
    protected Groupe copyInto(Groupe copyObj, Connection con) throws TorqueException
    {
        return copyInto(copyObj, true, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     */
    protected Groupe copyInto(Groupe copyObj, boolean deepcopy) throws TorqueException
    {
        copyObj.setIdGroupe(idGroupe);
        copyObj.setNom(nom);

        copyObj.setIdGroupe( 0);

        if (deepcopy)
        {


        List vModuleGroupes = getModuleGroupes();
        if (vModuleGroupes != null)
        {
            for (int i = 0; i < vModuleGroupes.size(); i++)
            {
                ModuleGroupe obj = (ModuleGroupe) vModuleGroupes.get(i);
                copyObj.addModuleGroupe(obj.copy());
            }
        }
        else
        {
            copyObj.collModuleGroupes = null;
        }


        List vEtudiants = getEtudiants();
        if (vEtudiants != null)
        {
            for (int i = 0; i < vEtudiants.size(); i++)
            {
                Etudiant obj = (Etudiant) vEtudiants.get(i);
                copyObj.addEtudiant(obj.copy());
            }
        }
        else
        {
            copyObj.collEtudiants = null;
        }
        }
        return copyObj;
    }
        
    
    /**
     * Fills the copyObj with the contents of this object using connection.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     * @param con the database connection to read associated objects.
     */
    protected Groupe copyInto(Groupe copyObj, boolean deepcopy, Connection con) throws TorqueException
    {
        copyObj.setIdGroupe(idGroupe);
        copyObj.setNom(nom);

        copyObj.setIdGroupe( 0);

        if (deepcopy)
        {


        List vModuleGroupes = getModuleGroupes(con);
        if (vModuleGroupes != null)
        {
            for (int i = 0; i < vModuleGroupes.size(); i++)
            {
                ModuleGroupe obj = (ModuleGroupe) vModuleGroupes.get(i);
                copyObj.addModuleGroupe(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collModuleGroupes = null;
        }


        List vEtudiants = getEtudiants(con);
        if (vEtudiants != null)
        {
            for (int i = 0; i < vEtudiants.size(); i++)
            {
                Etudiant obj = (Etudiant) vEtudiants.get(i);
                copyObj.addEtudiant(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collEtudiants = null;
        }
        }
        return copyObj;
    }
    
    

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public GroupePeer getPeer()
    {
        return peer;
    }

    /**
     * Retrieves the TableMap object related to this Table data without
     * compiler warnings of using getPeer().getTableMap().
     *
     * @return The associated TableMap object.
     */
    public TableMap getTableMap() throws TorqueException
    {
        return GroupePeer.getTableMap();
    }


    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Groupe:\n");
        str.append("IdGroupe = ")
           .append(getIdGroupe())
           .append("\n");
        str.append("Nom = ")
           .append(getNom())
           .append("\n");
        return(str.toString());
    }
}
